import axios from "axios";
const request_fileUpload = axios.create({
    timeout:5000
})
request_fileUpload.interceptors.request.use(config => {
    config.headers["Content-Type"] = 'form-data; charset=utf-8';
    return config;
},error => {
    return Promise.reject(error);
})
export default request_fileUpload;
//response拦截器
//在调用接口响应后，统一处理返回结果
request_fileUpload.interceptors.response.use(
    response => {
        let res = response.data
        //如果返回文件
        if (response.config.responseType === 'blob'){
            return res
        }
        if (typeof res === 'String'){
            res = res ? JSON.parse(res) : res

        }
        return res
    },
    error => {
        console.log("err", error)
        return Promise.reject(error)
    }
)